<script>



import axios from "axios";
import { EventBus } from '../eventBus';
export default {
  name: 'AsidePage',
  components : {



  },
  data(){
    return {
      categories :[],

    }



  },
  mounted() {
    console.log('Component mounted.')
    this.loadcategoriers();
    EventBus.$on('updatecate', this.updatecate);
    },

  methods: {
    selectPhone(name){

      let url = "https://youxuan-zua-api.tulan.wang/admin/ysf-categories/findByName?name=" +name
      axios.get(url).then(res => {
        let result = res.data;
        console.log(result)

        EventBus.$emit('updateUsers', result.data);


  })
},
    updatecate(newupdatecate) {
      this.categories = newupdatecate; // 更新 users 数据
    },


    loadAllUser() {


      let url = "https://youxuan-zua-api.tulan.wang/admin/ysf-products/page"
      axios.get(url).then(res => {
        let result = res.data;
        console.log(result)
        EventBus.$emit('updateUsers', result.data);
      })
    },
    loadcategoriers() {
      let url2 = 'https://youxuan-zua-api.tulan.wang/admin/ysf-categories/page?size=20'
      axios.get(url2).then(res1 => {
        let result1 = res1.data;
        this.categories = result1.data
        console.log(result1.data)
      })
    }
  }
}

</script>

<template>
  <div>

    <div v-for ="cate in categories" :key="cate.categoriesId">

     <el-button type="primary" plain  @click="selectPhone(cate.categoriesName)" >{{cate.categoriesName}}</el-button><br>


    </div>

</div>


</template>

<style scoped>


</style>